home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-03-20 | 5.4 KB | 259 lines | [mlts/slnk] |
- ! "AT&T DataPort Modem - 3/20/93"
- ! Written by George Warner
- ! warnergt@aloft.att.com
- ! It works for me, I hope it works for you.
- ! After much experimenting, it seems 100% to me.
- @ORIGINATE
- @ANSWER
- !
- @LABEL 1
- note "Resetting serial port." 2
- serreset 19200, 0, 8, 1
- note "Syncing the modem." 2
- ! first sync up the modem
- matchclr
- matchstr 1 4 "OK\13\10"
- settries 0
- @LABEL 2
- write "AT\13"
- matchread 30
- inctries
- iftries 4 59
- jump 2
- @LABEL 3
- !
- ! Now, recall the modems factory configuration
- @LABEL 4
- note "Modem synchronized. Setting up." 2
- matchstr 1 6 "OK\13\10"
- ! Factory default options, disable echo, ignore DTR
- ! Disable error control, disable data compression; ARA handles this
- write "AT&F0E0&D0\\N0%C0\13"
- matchread 30
- inctries
- iftries 2 59
- ! Modem is not responding, reset
- DTRClear
- pause 5
- DTRSet
- jump 4
- !
- @LABEL 6
- ! Set RTS/CTS handshaking ON in the serial port (CTS is the 2nd 1 in the
- ! HSReset command below, and RTS is the 6th 1 in the HSReset command below).
- HSReset 0 1 0 0 0 1
- !
- ! Did the user turn on the speaker flag?
- ifstr 2 8 "1"
- @LABEL 7
- pause 5
- matchstr 1 8 "OK\13\10"
- write "ATM0\13"
- matchread 30
- jump 59
- !
- ! The modem is ready. So enable answering, or originate a call
- !
- @LABEL 8
- ifANSWER 30
- note "Dialing ^1" 2
- write "ATS0=0DT^1\13"
- !
- @LABEL 9
- matchstr 1 10 "CONNECT 300\13\10"
- matchstr 2 11 "CONNECT 1200\13\10"
- matchstr 3 12 "CONNECT 2400\13\10"
- matchstr 4 14 "CONNECT 4800\13\10"
- matchstr 5 15 "CONNECT 7200\13\10"
- matchstr 6 16 "CONNECT 9600\13\10"
- matchstr 7 17 "CONNECT 12000\13\10"
- matchstr 8 18 "CONNECT 14400\13\10"
- matchstr 9 50 "NO CARRIER\13\10"
- matchstr 10 50 "ERROR\13\10"
- matchstr 11 52 "NO DIALTONE\13\10"
- matchstr 12 53 "BUSY\13\10"
- matchstr 13 54 "NO ANSWER\13\10"
- matchread 700
- jump 59
- !
- @LABEL 10
- note "Communicating at 300 bps." 2
- COMMUNICATINGAT 300
- jump 19
- !
- @LABEL 11
- note "Communicating at 1200 bps." 2
- COMMUNICATINGAT 1200
- jump 19
- !
- @LABEL 12
- note "Communicating at 2400 bps." 2
- COMMUNICATINGAT 2400
- jump 19
- !
- @LABEL 14
- note "Communicating at 4800 bps." 2
- COMMUNICATINGAT 4800
- jump 19
- !
- @LABEL 15
- note "Communicating at 7200 bps." 2
- COMMUNICATINGAT 7200
- jump 19
- !
- @LABEL 16
- note "Communicating at 9600 bps." 2
- COMMUNICATINGAT 9600
- jump 19
- !
- @LABEL 17
- note "Communicating at 12000 bps." 2
- COMMUNICATINGAT 12000
- !
- @LABEL 18
- note "Communicating at 14400 bps." 2
- COMMUNICATINGAT 14400
- !
- @LABEL 19
- ! If the script is answering a telephone call, just exit right away.
- ifANSWER 20
- ! give the other end some time (3 seconds)
- pause 30
- @LABEL 20
- ! Exit successfully.
- exit 0
- !
- ! @ANSWER
- ! Set up the modem to answer
- @LABEL 30
- note "Waiting for incoming call..." 2
- matchclr
- matchstr 1 31 "OK\13\10"
- write "ATS0=1\13"
- matchread 30
- jump 59
- !
- @LABEL 31
- matchstr 1 32 "RING\13\10"
- matchstr 2 11 "CONNECT 1200\13\10"
- matchstr 3 12 "CONNECT 2400\13\10"
- matchstr 4 14 "CONNECT 4800\13\10"
- matchstr 5 15 "CONNECT 7200\13\10"
- matchstr 6 16 "CONNECT 9600\13\10"
- matchstr 7 17 "CONNECT 12000\13\10"
- matchstr 8 18 "CONNECT 14400\13\10"
- matchstr 9 50 "NO CARRIER\13\10"
- matchstr 10 59 "ERROR\13\10"
- matchstr 11 52 "NO DIALTONE\13\10"
- matchstr 12 53 "BUSY\13\10"
- matchstr 13 54 "NO ANSWER\13\10"
- matchread 700
- jump 31
- !
- @LABEL 32
- !
- ! What is userhook 1 ? Here's the idea: Either this script
- ! controls a server that is waiting to answer the telephone, or it's waiting
- ! for a callback to a connection that was initiated. AppleTalk Remote Access
- ! does a "passive" listen on the serial port (via the Serial Port Arbitrator)
- ! so that other communications applications can use the serial port when ARA
- ! is not using it. When a call comes in for a server or callback, there
- ! will be about 5-14 seconds while the modems negotiate the connection.
- ! What would happen if a communications application on this Macintosh
- ! wanted to use the serial port during that time? Both connections
- ! would fail. The userhook 1 command tells ARA to mark the serial port in
- ! use. When that happens, applications that want to use the serial port will
- ! be told it's busy, and the incoming connection can complete. With that in
- ! mind, the strategy below is: When the modem receives a ring, jump to label
- ! 32, issue the userhook 1 command, then jump back up to label 31, wait for
- ! the connect result code and continue processing the script.
- !
- userhook 1
- note "Answering phone..." 2
- jump 31
- !
- ! 50: error messages
- !
- @LABEL 50
- ! No carrier.
- exit -6021
- !
- @LABEL 52
- ! No dial tone.
- exit -6020
- !
- @LABEL 53
- ! Busy
- exit -6022
- !
- @LABEL 54
- ! No answer.
- exit -6023
- !
- @LABEL 59
- ! Modem error.
- exit -6019
- !
- ! Hang up the modem
- !
- @HANGUP
- @LABEL 60
- settries 0
- @LABEL 61
- matchclr
- matchstr 1 63 "OK\13\10"
- matchstr 2 63 "NO CARRIER\13\10"
- matchstr 3 63 "ERROR\13\10"
- write "ATH\13"
- matchread 30
- inctries
- iftries 3 63
- ! no response, try escape sequence
- matchclr
- matchstr 1 62 "OK\13\10"
- pause 20
- write "+++"
- matchread 40
- !
- ! No response from modem, toggle DTR
- !
- DTRClear
- pause 5
- DTRSet
- pause 5
- jump 61
- !
- @LABEL 62
- pause 5
- matchclr
- matchstr 1 63 "OK\13\10"
- matchstr 2 63 "NO CARRIER\13\10"
- matchstr 3 63 "ERROR\13\10"
- write "ATH\13"
- matchread 70
- jump 61
- !
- ! Recall factory settings
- !
- @LABEL 63
- pause 5
- matchclr
- matchstr 1 64 "OK\13\10"
- ! Factory default options, disable echo, ignore DTR
- ! Disable error control, disable data compression; ARA handles this
- write "AT&F0E0&D0\\N0%C0\13"
- matchread 30
- !
- ! Turn off auto answer
- @LABEL 64
- pause 5
- write "ATS0=0\13"
- matchstr 1 65 "OK\13\10"
- matchread 30
- !
- ! Add delay to make sure other side of connection hangs up for call back.
- !
- @LABEL 65
- pause 5
- exit 0
-